"use strict";
cc._RF.push(module, '8ae69exp+ZJwa03WcJYt9nR', 'Bullet');
// Script/Bullet.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var AppDef_1 = require("./Core/AppDef");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var Bullet = /** @class */ (function (_super) {
    __extends(Bullet, _super);
    function Bullet() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.spriteFrames = [];
        _this.p = cc.v3(0, 0, 0);
        _this.bulletType = AppDef_1.WEAPON_TYPE.My;
        _this.from = 0;
        return _this;
    }
    Bullet.prototype.onLoad = function () {
        this.onReset();
        this.node.getComponent(cc.RigidBody).enabledContactListener = true;
    };
    Bullet.prototype.onReset = function () {
        this.onUnScheduleMove();
        this.p = cc.v3(0, 0, 0);
        this.bulletType = AppDef_1.WEAPON_TYPE.My;
        this.from = 0;
    };
    Bullet.prototype.setP = function (p) {
        // this.p = p.multiplyScalar(1);
        this.p = p;
    };
    Bullet.prototype.setBulletType = function (bulletType, from) {
        this.bulletType = bulletType;
        this.node.getComponent(cc.Sprite).spriteFrame = this.spriteFrames[AppDef_1.WEAPON_TYPE.My];
        // if (bulletType == WEAPON_TYPE.My){
        //     cc.resources.load(BULLET_1, cc.SpriteFrame, null, function (err, spriteFrame) {
        //     });
        // }else {
        //     cc.resources.load(BULLET_2, cc.SpriteFrame, null, function (err, spriteFrame) {
        //         this.node.getComponent(cc.Sprite).spriteFrame = spriteFrame;
        //     });
        // }
        this.from = from;
        this.onScheduleMove();
    };
    Bullet.prototype.onMove = function () {
        cc.log("_--onMove  this.p.x ", this.p.x, "  this.p.y ", this.p.y);
        this.node.position = this.node.position.add(this.p);
    };
    Bullet.prototype.onScheduleMove = function () {
        var _this = this;
        this.schedule(function () {
            _this.onMove();
        }, 0.02);
    };
    Bullet.prototype.onUnScheduleMove = function () {
        cc.log("_--onUnScheduleMove");
        this.unscheduleAllCallbacks();
        // this.unschedule(()=>{
        //     this.onMove();
        // })
        this.p = cc.v3(0, 0, 0);
    };
    __decorate([
        property(cc.SpriteFrame)
    ], Bullet.prototype, "spriteFrames", void 0);
    Bullet = __decorate([
        ccclass
    ], Bullet);
    return Bullet;
}(cc.Component));
exports.default = Bullet;

cc._RF.pop();